// 
//  Copyright (C) 2009 Jacek Trubłajewicz
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 

using System;
using System.Drawing;
using System.IO;
using Mono.Unix;
using NLog;

namespace wxGadu
{
	public class HistoryChatPanel : wx.Panel
	{
		#region IDs
		private enum Id
		{
			messageWindow
		}
		#endregion	

		#region windows
		private CopyHtmlWindow messageWindow;
		private wx.BoxSizer topSizer;
		#endregion

		#region data members
		private string htmlCode;
		private MainFrame mainFrame;
		#endregion
		
#if LOG
		private Logger logger = LogManager.GetCurrentClassLogger();
#endif
		
		public HistoryChatPanel(wx.Window parent): 
			base(parent)
		{
			wx.SplitterWindow splitter = (wx.SplitterWindow) parent;
			HistoryFrame historyFrame =  (HistoryFrame) splitter.Parent;
			mainFrame = (MainFrame) historyFrame.MainFrame;
			
			messageWindow = new CopyHtmlWindow(this, (int) Id.messageWindow, wx.Window.wxDefaultPosition,
			                                  new Size(350, 350), wx.HtmlWindow.wxHW_SCROLLBAR_AUTO|wx.Window.wxBORDER_MASK,
			                                   mainFrame);
			messageWindow.Borders = 0;
			
			wx.Font msgFont;
			string fontFace;
			int fontSize;
			if (mainFrame.AppCfg.UserConf.TopChatWindowFont == null)
				msgFont = wx.SystemSettings.GetFont(wx.SystemFont.wxSYS_DEFAULT_GUI_FONT);
			else
				msgFont = (wx.Font) mainFrame.AppCfg.UserConf.TopChatWindowFont;
			
			
			fontSize = msgFont.PointSize;
			fontFace = msgFont.FaceName;
			int[] fontSizes = new int[7];
			for(int i=0; i < fontSizes.Length; i++)
				fontSizes[i] = fontSize;
			messageWindow.SetFonts(fontFace, fontFace, fontSizes);
			
			DoLayout();
		}

		
		private void DoLayout()
		{
			topSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
			{
				topSizer.Add(messageWindow, 1, wx.Stretch.wxEXPAND);
			}
			
			topSizer.Fit(this);
			topSizer.SetSizeHints(this);
			this.Sizer = topSizer;
			
		}

		
		public void SetNewPage(string htmlCode)
		{
			messageWindow.SetPage(htmlCode);
		}
	}
}
